<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.roadmap.struts.action.ActionConst"%>
<%@ page import="com.roadmap.common.RdcResourceBundle" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String currentAction = request.getParameter(ActionConst.Method_Symbol);
if(currentAction == null || (!currentAction.equalsIgnoreCase("friend") && !currentAction.equalsIgnoreCase("me"))) {
	currentAction = "friend";
}
Object removeSysInfo = session.getAttribute(ActionConst.REMOVE_SYSINFO_HOME);
if(removeSysInfo == null) {
	session.setAttribute(ActionConst.REMOVE_SYSINFO_HOME, true);
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/> 
<script type="text/javascript" src="res/js/func.js"></script>
<link href="res/css/layout.css" rel="stylesheet" type="text/css" media="all" />
<link href="res/css/home.css" rel="stylesheet" type="text/css" media="all" />
<title><%=session.getAttribute(ActionConst.Aspirant_Name_In_Session) %>的首页&nbsp;|&nbsp;<%=RdcResourceBundle.COMPANY_NAME %></title>
</head>

<body>
	<jsp:include page="/admin/myheader.jsp"></jsp:include>
	
	<!-- main body -->
	<div class="mainbody">
	<div class="myhome">	
		<div class="left-part">
			<jsp:include page="/pagelet/userLinksPagelet.jsp"/>
			<jsp:include page="/pagelet/lifeLinksPagelet.jsp"/>

			<div class="slidebar">
				<ul>
					<li class="title">好友来访<span class="float-right"><a href="friend.do?act=visit">全部</a></span></li>
					
					<logic:present name="visitors">
					<logic:iterate id="visitor" name="visitors">
					<li><a href="aspirant.do?uid=<bean:write name='visitor' property='id'/>"><bean:write name='visitor' property='name'/></a>
						<em><bean:write name='visitor' property='createdTime' format='yyyy.MM.dd HH:mm'/></em>
					</li>
					</logic:iterate>
					</logic:present>
					
					<logic:notPresent name="visitors">
					<li>暂无好友访问<li>
					</logic:notPresent>
				</ul>
			</div>
		</div>
		
		<div class="middle-part">
			<%if (removeSysInfo == null) {%>
			<div class="sysinfo">
				<p>尊敬的用户：</p>
				<p>由于网站在不断完善中，您可能会遇到网站不能访问的情况，在此很抱歉，希望您能谅解。此外，网站基于Firefox和IE8开发，推荐您使用Firefox3.5或其以上版本、IE8访问本网站。</p>
			</div>
			<%} %>
			
			<div class="title-sp">最新动态</div>
			<div class="navg">
				<ul id="latestActivities">
					<li><a id="friend" href="home.do?act=friend" onfocus="this.blur();">好友的</a></li>
					<li><a id="me" href="home.do?act=me" onfocus="this.blur();">自己的</a></li>
				</ul>
			</div>
			
			<div class="activityList">
				<logic:notPresent name="activities"><span class="prompt-message">暂无最新动态</span></logic:notPresent>
				<logic:present name="activities">
				<ul>
					<% String tempDate = null; %>
					<logic:iterate id="action" name="activities">
					<bean:define id="createDate" name="action" property="createdTime"/>
					<% 
						String date = createDate.toString();
						if(date != null) {
							if(tempDate == null || date.indexOf(tempDate) == -1) {
								tempDate = date.split(" ")[0];
								out.println("<li><strong>" + tempDate + "</strong></li>");
							}
						}
					%>
					<li><em><bean:write format='HH:mm' name='action' property='createdTime'/></em>
						<a href="aspirant.do?uid=<bean:write name='action' property='dispatcherId'/>"><bean:write name="action" property="dispatcherName"/></a>&nbsp;<bean:write name='action' property='activity'/><logic:notEmpty name='action' property='recipientId'><a href="aspirant.do?uid=<bean:write name='action' property='recipientId'/>">&nbsp;<bean:write name="action" property="recipientName"/></a>的</logic:notEmpty><bean:write name='action' property='entryType'/>&nbsp;<a href='<bean:write name='action' property='actionURL'/>'><bean:write name='action' property='entryDesc'/></a></li>
					</logic:iterate>
				</ul>
				</logic:present>
			</div>
			
		</div><!-- middle-part -->
		
		<div class="right-part">
			
		</div>
		
	</div><!-- myhome -->
	
	<div class="clear-div"></div>
	</div><!-- mainbody -->
	
	<jsp:include page="/res/jsp/footer.jsp"></jsp:include>
	
<script type="text/javascript">
	window.onload = function() {
		var act = "<%=currentAction %>";
		var kids = $("latestActivities").getElementsByTagName("LI");	
		for (i = 0; i < kids.length; i += 1){
			kids[i].id = (act === kids[i].firstChild.id) ? "selected" : "unselected";
		}
	}
</script>	
</body>

</html>
